import {
  Body,
  Controller,
  Get,
  Post,
  Put,
  Query,
  Param,
} from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { YixiantongService } from './yixiantong.service';
import { YixiantongFieldsGoods } from 'src/entities/yixiantong';
import { YixiantongCities, YixiantongFieldItem } from 'src/entities/yixiantong.type';

@ApiTags('一线通 - 【公共资源】')
@Controller('/api/yixiantong')
export class YixiantongController {
  constructor(
    private readonly yixiantongService: YixiantongService,
  ) {}

  @ApiOperation({
    summary: '获取一线通 App 城市信息',
    description: '获取一线通 App 城市信息',
  })
  @Get('/getYixiantongFields')
  public getYixiantongFields() {
    return this.yixiantongService.getFields();
  }

  @ApiOperation({
    summary: '获取一线通 App 首页数据',
    description: '获取一线通 App 首页数据'
  })
  @Get('/getHomeDatas')
  public getHomeDatas(@Query('cityId') cityId: string) {
    return this.yixiantongService.getHomeDatas(cityId);
  }

  @ApiOperation({
    summary: '获取一线通 App 列表页数据',
    description: '获取一线通 App 列表页数据'
  })
  @Get('/getListDatas')
  public getListDatas(
    @Query('cityId') cityId: YixiantongCities,
    @Query('field') field: YixiantongFieldItem,
  ) {
    return this.yixiantongService.getListDatas(cityId, field);
  }

  @ApiOperation({
    summary: '获取一线通 App 详情页数据',
    description: '获取一线通 App 详情页数据'
  })
  @Get('/getDetail/:id')
  public getDetail(@Param('id') id: string) {
    return this.yixiantongService.getDetail(id);
  }

  @ApiOperation({
    summary: '获取一线通 App 搜索页数据',
    description: '获取一线通 App 搜索页数据'
  })
  @Get('/searchAction')
  public searchAction(@Query('keyword') keyword: string) {
    return this.yixiantongService.searchAction(keyword);
  }
}
